package com.ht.module.info.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import com.ht.module.info.service.IInfoMerchantsService;
import com.ht.util.*;
import com.ht.module.info.entity.InfoMerchants;

import javax.validation.Valid;
import java.util.*;


/**
 * <p>
 * 商户表 前端控制器
 * </p>
 *
 * @author Auto-generator
 * @since 2021-12-03
 */
@Api(tags = "商户表 ")
@RestController
@RequestMapping("/info-merchants")
public class InfoMerchantsController {

    
    @Autowired
    private IInfoMerchantsService iInfoMerchantsService;


    @ApiOperation(value = "商户入驻")
    @PostMapping("/notLogin/merchantsIn")
    public JsonResult merchantsIn(@Valid InfoMerchants infoMerchants){
        iInfoMerchantsService.merchantsIn(infoMerchants);
        return JsonResult.success();
    }
    /**
    * 分页查询
    */
    @ApiOperation(value = "分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<InfoMerchants> pager, InfoMerchants infoMerchants){
        return JsonResult.success(iInfoMerchantsService.findPage(pager,infoMerchants));
    }


    /**
    * 通过id查询
    */
    @GetMapping("/get-by-id/{id}")
    @ApiOperation(value = "通过id查询")
    public JsonResult getById(@PathVariable(value = "id") String id){
        return JsonResult.success(iInfoMerchantsService.getById(id));
    }




    /**
     * 通过id查询
     */
    @GetMapping("/findByMe")
    @ApiOperation(value = "获取当前用户商户信息")
    public JsonResult findByMe(){
        return JsonResult.success(iInfoMerchantsService.findByMe());
    }

    /**
    * 通过id删除
    */
    @DeleteMapping("/delete-by-id/{id}")
    @ApiOperation(value = "删除")
    public JsonResult delete(@PathVariable(value = "id") String id){
        iInfoMerchantsService.deleteById(id);
        return JsonResult.success();
    }

    /**
    * 修改
    */
    @PutMapping("/update")
    @ApiOperation(value = "修改")
    public JsonResult updateById(@RequestBody @Valid InfoMerchants infoMerchants){
        iInfoMerchantsService.updateById(infoMerchants);
        return JsonResult.success();
    }

}
